/// <reference path="../../typings/blockly.d.ts" />
export function svgchange(_b: boolean) {

}

/**
 * 撤销 删除
 * @param redo 
 */
export function undo(redo: boolean) {
  Blockly.mainWorkspace.undo(redo)
}

/**
 * 清理块
 */
export function clear() {
  Blockly.mainWorkspace.clear();
}

export function appendDomToWorkspace(xml: string) {
  clear()
  let xmldom = Blockly.Xml.textToDom(xml)
  Blockly.Xml.appendDomToWorkspace(xmldom, Blockly.mainWorkspace)
  setTimeout(() => {
    undo(false)
    undo(true)
  }, 1)
}


export function cleanUp() {
  Blockly.mainWorkspace.clearUndo()
}


export function zoomToFit(workspace: Blockly.WorkspaceSvg) {
  workspace.zoomToFit()
}

export function undoStack_() {
  return Blockly.mainWorkspace.undoStack_
}

export function redoStack_() {
  return Blockly.mainWorkspace.redoStack_
}

export function zoom(workspace: Blockly.WorkspaceSvg, t: boolean) {
  const x = workspace.getScale()
  workspace.setScale(t ? x + 0.2 : x - 0.2)
}

export function getxml() {
  const xml = Blockly.Xml.workspaceToDom(Blockly.mainWorkspace)
  return Blockly.Xml.domToPrettyText(xml)
}

export function getpython() {

}
